<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .p1 {
      color: red;
    }
    .font-blue {
      color: blue;
    }
    .bg-blue {
      background-color: blue;
    }
    .vip {
      color: gold;
    }
    .normal {
      color: #333;
    }
    .blue {
      color: blue;
    }
    .pink {
      color: pink;
    }
  </style>
</head>
<body>
  <div id="app">
    <h1>动态绑定class和style</h1>
    <!-- 1.直接绑定变量 -->
    <p v-bind:class="p1">我是P标签</p>
    <!-- 2.字符串拼接 -->
    <p v-bind:class="'bg-'+p2">我是P标签</p>
    <!-- 3.三元表达式 -->
    <p v-bind:class="[isVIP?'vip':'normal', 'top' , 'nav', {'const': true}]">111我是P标签</p>
    <!-- 4.tf判断 -->
    <p v-bind:class="{'vip': isVIP}">我是P标签</p>
    <button @click="isVIP = true">充满</button>
    <p v-for="(item,index) in heros" :class="[item.sex == 1 ? 'blue' : 'pink']">{{item.name}}</p>
    <hr>
    <hr>
    <p :style="{color: dawa,'font-size': font1}">葫芦娃-大娃</p>
    <p :style="{color: erwa, 'font-size': font2}">葫芦娃-二娃</p>
    <p :style="{color: sanwa, 'font-size': font3+'px'}">葫芦娃-三娃</p>
    <p :style="style1">蛇精</p>
  </div>
  <script src="./vue.js"></script>
  <script>
    let vm = new Vue({
      el: '#app',
      data: {
        p1: 'p1',
        p2: 'blue',
        isVIP: false,
        heros: [
          {name: '宋江', sex: 1},
          {name: '李逵', sex: 1},
          {name: '扈三娘', sex: 2},
        ],
        dawa: 'red',
        erwa: 'orange',
        sanwa: 'yellow',
        font1: '60px',
        font2: '40px',
        font3: 20,
        style1: {
          border: '2px solid red',
          color: 'red'
        }
      }
    });
  </script>
</body>
</html>